<template>
  <div>
    <div class="appNav">
      <el-menu
        :default-active="$route.path"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#32F2E5"
      >
        <el-menu-item
          :index="item.path"
          v-for="item in navList"
          :key="item.id"
          @click="goto(item.path)"
        >
          <i :class="item.icon"></i>
          <span slot="title">{{ item.title }}</span>
        </el-menu-item>
      </el-menu>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      navList: [
        {
          id: 1,
          title: "用户管理",
          path: "/home/user",
          icon: "el-icon-user-solid"
        },
        {
          id: 2,
          title: "商品管理",
          path: "/home/goods",
          icon: "el-icon-s-goods"
        },
        {
          id: 3,
          title: "订单管理",
          path: "/home/order",
          icon: "el-icon-s-order"
        },
        {
          id: 4,
          title: "评论管理",
          path: "/home/comment",
          icon: "el-icon-s-comment"
        }
      ]
    };
  },

  components: {},

  methods: {
    goto(path) {
      this.$router.push(path);
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  }
};
</script>

<style scoped>
.appNav {
  position: absolute;
  top: 50px;
  left: 0;
  bottom: 0;
  width: 200px;
  overflow-y: auto;
  background: rgb(84, 92, 100);
}
.el-menu{
  border: 0;
}
</style>